<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>基础信息</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link rel="stylesheet" type="text/css" media="screen" href="./css/userControl.css">
    <link rel="stylesheet" type="text/css" media="screen" href="./css/normalize.css">
    <link rel="stylesheet" href="./css/font/iconfont.css">
    <link rel="stylesheet" href="./css/basicInformation.css">
</head>

<body>
<div class="max">
    <div class="_left">
        <iframe name="header_iframe" width=250px height="950px"
                src="components/NavigationBar.jsp" frameborder=0 scrolling="no"></iframe>
    </div>
    <div class="catalog">当前位置：<a href="#">/ 基础信息 /</a></div>
    <!-- 主体 -->
    <div class="_right_top">
        <div style="margin-left: 0;">
            <iframe id="type" name="header_iframe" height="160px" width=100% src="components/Header.jsp" frameborder=0
                    scrolling="no"></iframe>
        </div>
        <form action="CompanyServlet?type=queryAll" method="post">
            <div class="_right_top_item">
                <h2>企业名称</h2><input type="text" name="companyName" placeholder="请输入企业名称">
                <h2>营业注册号</h2><input type="text" name="code" placeholder="请输入营业执照注册号">
                <button class="_right_top_item_btn01 iconfont icon-sousuo">搜索</button>
            </div>
        </form>
        <div class="buttons">
            <button class=" buttons_btn1"><span class="iconfont icon-tianjia"></span>新增</button>
        </div>
        <div class="right">


            <div class="info" style="overflow-y: scroll;height: 700px">
                <table>
                    <tr>
                        <th>企业名称</th>
                        <th>营业执照注册号</th>
                        <th>成立时间</th>
                        <th>主要服务领域</th>
                        <th>固定电话</th>
                        <th>操作</th>
                    </tr>
                    <c:forEach items="${companies}" var="company">
                        <tr>
                            <td>${company.companyShortName}</td>
                            <td>${company.registrationNumber}</td>
                            <td>${company.establishmentDate}</td>
                            <td>${company.mainServicesRange}</td>
                            <td>${company.phone}</td>
                            <td>
                                <button class="updateInfo" onclick="update(this)" value="${company}">修改</button>
                                <span style="font-size: 20px;">|</span>
                                <button class="delInfo"><a
                                        href="/CompanyServlet?type=deleteById&company_id=${company.companyId}"
                                        onclick="return window.confirm('你确定要删除吗？删除后数据不可以恢复，请谨慎！')">删除</a>
                                </button>
                            </td>
                        </tr>
                    </c:forEach>
                    <tr>
                        <td colspan="6">
                            总共${pages}页，共${totals}条
                            <a href="CompanyServlet?type=queryAll&pageNow=1">首页</a>
                            <a href="CompanyServlet?type=queryAll&pageNow=${pageNow<=1?1:pageNow-1}">上一页</a>
                            <a href="CompanyServlet?type=queryAll&pageNow=${pageNow>=pages?pages:pageNow+1}">下一页</a>
                            <a href="CompanyServlet?type=queryAll&pageNow=${pages}">尾页</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="overlay">
            <div class="update">
                <div class="head_box">
                    <span>修改信息</span>
                </div>
                <div class="body_box">
                    <form action="CompanyServlet?type=updateById" method="post"
                          style="overflow-y: scroll;height: 600px;">
                        <table class="table_Basic">
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业编号:
                                    </div>
                                    <div><input type="text" class="updateObject" name="company_id"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业名称:
                                    </div>
                                    <div><input type="text" class="updateObject" name="company_name"
                                                placeholder="请输入企业名称"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业简称:
                                    </div>
                                    <div><input type="text" class="updateObject" name="company_short_name"
                                                placeholder="请输入企业简称"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业英文名:
                                    </div>
                                    <div><input type="text" class="updateObject" name="company_english_name"
                                                placeholder="请输入企业英文名"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 营业执照注册号:
                                    </div>
                                    <div><input type="text" class="updateObject" name="registration_number"
                                                placeholder="请输入营业执照注册号"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 注册资金:
                                    </div>
                                    <div><input type="text" class="updateObject" name="registered_fund"
                                                placeholder="请输入注册资金"></div>
                                </td>

                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 法人姓名:
                                        </div>
                                        <div><input type="text" class="updateObject" name="legal_person_name"
                                                    placeholder="请输入法人姓名"></div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 在职员工数:
                                        </div>
                                        <div><input type="text" class="updateObject" name="staff_number"
                                                    placeholder="请输入在职员工数"></div>
                                    </div>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 成立时间:
                                    </div>
                                    <div><input class="updateObject" name="establishment_date" type="date"></div>
                                </td>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 主要服务领域:
                                    </div>
                                    <div><textarea class="updateObject" name="main_services_range"
                                                   style="height: 3.125rem;"></textarea></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"> 其他服务域:</div>
                                    <div><input type="text" class="updateObject" name="other_services_range"
                                                placeholder="请输入其他服务域"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 注册地址:
                                    </div>
                                    <div><input type="text" class="updateObject" name="registered_address"
                                                placeholder="请输入注册地址"></div>
                                </td>

                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 办公地址:
                                    </div>
                                    <div><input type="text" class="updateObject" name="work_address"
                                                placeholder="请输入办公地址"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 办公地址邮编:
                                    </div>
                                    <div><input type="number" class="updateObject" name="work_address_email"
                                                placeholder="请输入办公地址邮编"></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 服务地域范围:
                                        </div>
                                        <div><input type="text" class="updateObject" name="services_address_range"
                                                    placeholder="请输入服务地域范围"></div>
                                    </div>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 质量承诺:
                                    </div>
                                    <div><textarea class="updateObject" name="quality_commitment"
                                                   style="height: 3.125rem;"></textarea></div>
                                </td>

                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 固定电话:
                                        </div>
                                        <div><input type="text" class="updateObject" name="phone" placeholder="请输入固定电话">
                                        </div>
                                    </div>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"> 传真号码:</div>
                                        <div><input class="updateObject" name="fax_number" type="text"
                                                    placeholder="请输入传真号码"></div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"> 公司网址:</div>
                                        <div><input type="text" class="updateObject" name="company_url"
                                                    placeholder="请输入公司网址"></div>
                                    </div>

                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 反应承诺速度:
                                    </div>
                                    <div><textarea style="height: 3.125rem;" class="updateObject"
                                                   name="reaction_speed_commitment"></textarea></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic" style="margin-left: .9375rem;"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 公司优势描述:
                                    </div>
                                    <div><textarea style="height: 3.125rem;" class="updateObject"
                                                   name="company_advantage"></textarea></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span>
                                            是否有关联合作伙伴:
                                        </div>
                                        <div><input type="text" class="updateObject" name="company_partner"
                                                    placeholder="请输入公司网址"></div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span>
                                            是否涉及重大纠纷、诉讼、仲裁或行政处罚:
                                        </div>
                                        <div><input type="text" class="updateObject" name="company_dispute"
                                                    placeholder="请输入公司网址"></div>
                                    </div>

                                </td>

                            </tr>
                        </table>
                        <div class="footer_box">
                            <input type="button" class="cancel" value="取消"></input>
                            <input type="submit" class="confirm" value="确定"></input>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="add">
            <div class="update">
                <div class="head_box">
                    <span>添加信息</span>
                </div>
                <div class="body_box">
                    <form action="CompanyServlet?type=addCompany" method="post"
                          style="overflow-y: scroll;height: 600px;">
                        <table class="table_Basic">
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业名称:
                                    </div>
                                    <div><input type="text" name="company_name" placeholder="请输入企业名称"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 营业执照注册号:
                                    </div>
                                    <div><input type="text" name="registration_number" placeholder="请输入营业执照注册号"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业简称:
                                    </div>
                                    <div><input type="text" name="company_short_name" placeholder="请输入企业简称"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 注册资金:
                                    </div>
                                    <div><input type="text" name="registered_fund" placeholder="请输入注册资金"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 企业英文名:
                                    </div>
                                    <div><input type="text" name="company_english_name" placeholder="请输入企业英文名"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 成立时间:
                                    </div>
                                    <div><input name="establishment_date" type="date"></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 法人姓名:
                                        </div>
                                        <div><input type="text" name="legal_person_name" placeholder="请输入法人姓名"></div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 在职员工数:
                                        </div>
                                        <div><input type="text" name="staff_number" placeholder="请输入在职员工数"></div>
                                    </div>

                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 主要服务领域:
                                    </div>
                                    <div><textarea name="main_services_range" style="height: 3.125rem;"></textarea>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 注册地址:
                                    </div>
                                    <div><input type="text" name="registered_address" placeholder="请输入注册地址"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"> 其他服务域:</div>
                                    <div><input type="text" name="other_services_range" placeholder="请输入其他服务域"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 办公地址:
                                    </div>
                                    <div><input type="text" name="work_address" placeholder="请输入办公地址"></div>
                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 办公地址邮编:
                                    </div>
                                    <div><input type="number" name="work_address_email" placeholder="请输入办公地址邮编"></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 服务地域范围:
                                        </div>
                                        <div><input type="text" name="services_address_range" placeholder="请输入服务地域范围">
                                        </div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span> 固定电话:
                                        </div>
                                        <div><input type="text" name="phone" placeholder="请输入固定电话"></div>
                                    </div>

                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 质量承诺:
                                    </div>
                                    <div><textarea name="quality_commitment" style="height: 3.125rem;"></textarea></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"> 传真号码:</div>
                                        <div><input name="fax_number" type="text" placeholder="请输入传真号码"></div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"> 公司网址:</div>
                                        <div><input type="text" name="company_url" placeholder="请输入公司网址"></div>
                                    </div>

                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 反应承诺速度:
                                    </div>
                                    <div><textarea style="height: 3.125rem;"
                                                   name="reaction_speed_commitment"></textarea></div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div class="td_tableBasic">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span>
                                            是否有关联合作伙伴:
                                        </div>
                                        <div><select name="company_partner">
                                            <option>是</option>
                                            <option>否</option>
                                        </select></div>
                                    </div>
                                    <div class="td_tableBasic" style="margin-top: .625rem;">
                                        <div class="text_Basic"><span
                                                style="color: red;font-weight: 700;margin-right: 3px;">*</span>
                                            是否涉及重大纠纷、诉讼、仲裁或行政处罚:
                                        </div>
                                        <div><select name="company_dispute">
                                            <option>是</option>
                                            <option>否</option>
                                        </select></div>
                                    </div>

                                </td>
                                <td class="td_tableBasic">
                                    <div class="text_Basic" style="margin-left: .9375rem;"><span
                                            style="color: red;font-weight: 700;margin-right: 3px;">*</span> 公司优势描述:
                                    </div>
                                    <div><textarea style="height: 3.125rem;" name="company_advantage"></textarea></div>
                                </td>
                            </tr>
                        </table>
                        <div class="footer_box">
                            <input type="button" class="cancel01" value="取消"></input>
                            <input type="submit" class="confirm" value="确定"></input>
                        </div>
                    </form>
                </div>
            </div>
        </div>
</body>

<script>
    let updateInfo = document.querySelectorAll('.updateInfo')
    let overlay = document.querySelector('.overlay')
    let cancel01 = document.querySelector('.cancel01')
    let add1 = document.querySelector('.add')
    let cancel = document.querySelector('.footer_box').getElementsByTagName('input')[0]
    let add = document.querySelector('.buttons').getElementsByTagName('button')[0]
    let iFrame = document.querySelector('#type')

    iFrame.onload = function () {
        iFrame.contentWindow.postMessage(window.location.pathname.substr(window.location.pathname.lastIndexOf('/')), '*');
    }
    updateInfo.forEach((item, index) => {
        item.addEventListener('click', (e) => {
            overlay.style.display = 'block'
            e.stopPropagation()
        })
    })

    cancel.onclick = function (e) {
        overlay.style.display = "none";
    }
    cancel01.onclick = function (e) {

        add1.style.display = "none"
    }

    add.addEventListener('click', (e) => {
        add1.style.display = 'block'
        e.stopPropagation()
    })

    function update(value) {
        const object = value.value.substring(5).replace(/'/g, "").replace(/{/g, "").replace(/}/g, "");
        console.log(object);
        let matchList = object.match(/=([^,]*)/g);
        let dataList = matchList.map(match => match.substring(1))
        const input = document.getElementsByClassName('updateObject');
        for (let i = 0; i < dataList.length; i++) {
            input[i].value = dataList[i]
        }
    }
</script>

</html>